//
//  Originator.m
//  备忘录模式
//
//  Created by flannery on 2018/12/19.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "Originator.h"
@interface Originator ()
@property (nonatomic, strong) NSString* state;
@end

@implementation Originator

-(instancetype)initWithState:(NSString*)state{
    if(self = [super init]) {
        self.state = state;
    }
    return self;
}

- (void)setState:(NSString *)state{
    _state = state;
}

-(NSString*)getState{
    return self.state;
}

-(Memento*)saveStateToMemento{
    return [[Memento alloc]initWithState:self.state];
}

-(void)getStateFromMemento:(Memento*)memento{
    self.state = [memento getState];
}
@end
